angular.module('faApp')
  .service('shareService', [ function () { 
    var map = {};
    this.get = function (k,v) {
      return map[k] ? map[k] : v;
    }; 
    this.set = function(k,v){
      map[k] = v;
    };
    this.remove = function(k){
      delete map[k];
    };
  }])
  .service('sessionService', [ function () { 
    this.getItem = function (k,v) {
      return sessionStorage.getItem(k) || v;
    }; 
    this.setItem = function(k,v){
      sessionStorage.setItem(k,v);
    };
    this.removeItem = function(k){
      sessionStorage.removeItem(k);
    };
    this.clear = function(){
      sessionStorage.clear(); 
    };
  }])
  .service('operationService',['ajaxService',function(ajaxService){
    this.statCount = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("OPERATION_STAT_COUNT"),cfg || {}); 
    };
    //我的业绩,团队业绩
    //  /api/order/queryOrderOwnerUserCountAmount.shtml
    this.queryOrderOwnerUserCountAmount = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("queryOrderOwnerUserCountAmount"),cfg || {});
    };
    this.queryVistDetail = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("queryVistDetail"),cfg || {});
    };
    //关注客户
    this.customerFocus = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("customerFocus"),cfg || {});
    };
    this.listFaRevisitTask = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("listFaRevisitTask"),cfg || {});
    };
    this.updateFaRevisitTask = function(cfg){
      return ajaxService.jsonp(ajaxService.getApiUri("updateFaRevisitTask"),cfg || {});
    };


  }])
  .service('exportService', [ 'ajaxService',function (ajaxService) { 
    this.exportCSV = function (cfg,api) {
      cfg.pageSize && (cfg.pageSize = 100000);
      cfg.pageNo && (cfg.pageNo = 1);
      return ajaxService.export(ajaxService.getApiUri(api),cfg || {}); 
      
    }; 
  }])
;
 

